package com.cn.springcloudvaccine.controller.vaccinestation;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cn.springcloudvaccine.model.vaccinestion.YmStation;
import com.cn.springcloudvaccine.model.vaccinestion.YmStationWorkOrder;
import com.cn.springcloudvaccine.model.vaccinestion.YmStationWorkTime;
import com.cn.springcloudvaccine.service.inter.VaccineStationService;
import com.cn.springcloudvaccine.utils.ajax.AjaxRes;
import com.cn.springcloudvaccine.utils.commen.Const;
import com.cn.springcloudvaccine.utils.mybatis.Page;

@Controller
@ResponseBody
@RequestMapping("/vaccinestation")
public class VaccineStationController{
	
	@Autowired
	VaccineStationService vaccineStationService;
	
	/**
	 * 疫苗站新增
	 * 
	 * @param YmStation ymStation,YmStationWorkTime YmStationWorkTime
	 *           
	 * @return SUCC
	 */
	@RequestMapping("/insertVaccineStation")
	public AjaxRes insertVaccineStation(AjaxRes ajaxRes,YmStation ymStation,YmStationWorkTime YmStationWorkTime){
		try {
        	this.vaccineStationService.insertVaccineStationSer(ymStation, YmStationWorkTime);
            ajaxRes.setSucceed(Const.SAVE_SUCCEED);
        }catch (Exception e){
            ajaxRes.setFailMsg(e.getMessage());
        }
        return ajaxRes;
	}
	
	/**
	 * 疫苗站查询
	 * 
	 * @param YmStation ymStation
	 *           
	 * @return List<YmStation>
	 */
	@RequestMapping("/queryVaccineStation")
	public AjaxRes queryVaccineStation(AjaxRes ajaxRes,YmStation ymStation,Page<Object> page){
		try {
			List<YmStation> YmStations = this.vaccineStationService.queryVaccineStationSer(ymStation,page);
            ajaxRes.setSucceed(YmStations,Const.DATA_SUCCEED);
        }catch (Exception e){
            ajaxRes.setFailMsg(e.getMessage());
        }
        return ajaxRes;
	}
	
	/**
	 * 新增疫苗站疫苗详情的新增(包括时间段和对应的疫苗)
	 * 
	 * @param YmStationWorkOrder ymStationWorkOrder,String[] parameter(时间段workTimeDescId)
	 *           
	 * @return SUCC
	 */
	@RequestMapping("/insertVaccineStationDetail")
	public AjaxRes insertVaccineStationDetail(AjaxRes ajaxRes,YmStationWorkOrder ymStationWorkOrder,String[] parameter){
		try {
			this.vaccineStationService.insertVaccineStationDetailSer(ymStationWorkOrder,parameter);
            ajaxRes.setSucceed(Const.SAVE_SUCCEED);
        }catch (Exception e){
            ajaxRes.setFailMsg(e.getMessage());
        }
        return ajaxRes;
	}
	
	/**
	 * 查询某一个疫苗站疫苗(包括时间段和对应的疫苗)
	 * 
	 * @param YmStation ymStation
	 *           
	 * @return List<YmStation>
	 */
	@RequestMapping("/queryVaccineStationDetail")
	public AjaxRes queryVaccineStationDetail(AjaxRes ajaxRes,YmStation ymStation){
		try {
			List<YmStation> YmStations = this.vaccineStationService.queryVaccineStationDetailSer(ymStation);
            ajaxRes.setSucceed(YmStations,Const.SAVE_SUCCEED);
        }catch (Exception e){
            ajaxRes.setFailMsg(e.getMessage());
        }
        return ajaxRes;
	}
	
}
